<?php
Yii::app()->clientScript->registerScriptFile($this->adminPath."/js/jquery.min.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->adminPath."/js/art-dialog/jquery.artDialog.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->adminPath."/js/art-dialog/plugins/iframeTools.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->adminPath."/js/jquery-ui-1.8.11.custom.min.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->adminPath . '/js/jquery.validate.js', CClientScript::POS_END);
Yii::app()->clientScript->registerScriptFile($this->adminPath . '/js/jquery.form.js', CClientScript::POS_END);

?>
    <link rel="stylesheet" type="text/css" href="<?php echo $this->adminPath; ?>/css/jquery-ui.css" />
    <link rel="stylesheet" type="text/css" href="<?php echo $this->adminPath; ?>/js/art-dialog/skins/blue.css" />
    <!-- page title -->
    <div class="page-title" style="z-index: 780;">
        <div class="in" style="z-index: 770;">
            <div class="titlebar" style="z-index: 760;">
                <h2 class="title">重设密码</h2>
            </div>

            <div class="clear" style="z-index: 740;"></div>
        </div>
    </div>
    <style>
        .grid-view {
            padding: 0;
        }
        table.tablesorters {
            background-color: #CDCDCD;
            font-family: arial;
            font-size: 12px;
            margin: 0 0;
            text-align: left;
            width: 100%;
        }
        table.tablesorters thead tr th {
            background-position: right center;
            background-repeat: no-repeat;
            color: #333333;
            cursor: pointer;
        }
        table.tablesorters tbody td {
            padding: 12px;
            vertical-align: middle;
        }
        table.tablesorters tbody td {
            border: 1px solid #D8E4E9;
            color: #6C7D8C;
            padding: 12px;
            vertical-align: top;
        }
        table.tablesorters thead tr th, table.tablesorter tfoot tr th {
            -moz-border-bottom-colors: none;
            -moz-border-left-colors: none;
            -moz-border-right-colors: none;
            -moz-border-top-colors: none;
            background: url("<?php echo $this->adminPath; ?>/img/tableshorter/titlebg.png") repeat-x scroll center bottom #EFF3F8;
            border-color: -moz-use-text-color #CBDAE8;
            border-image: none;
            border-left: 1px solid #CBDAE8;
            border-right: 1px solid #CBDAE8;
            border-style: none solid;
            border-width: medium 1px;
            font-size: 8pt;
            padding: 12px;
        }
        table.tablesorters tbody tr.odd {
            background-color: #FFFFFF;
        }
        table.tablesorters tbody tr:hover {
            background-color: #E4ECF3;
        }
        .newLoding{
            background: url("<?php echo $this->adminPath; ?>/img/loading/6.gif") no-repeat scroll center bottom #EFF3F8;
        }
        .page.selected a{
            background:#3E7CAC ;
            color:#FFFFFF;
        }
        .grid-view .button-column {
            text-align: center;
            width: 30px;
        }
    </style>

    <div class="content">
        <div class="simplebox grid740" style="z-index: 500;">
            <form id="edit_user_passwd" >
            <div class="st-form-line" style="z-index: 580;">
                <span class="st-labeltext">用户名:</span>
                <?php echo Yii::app()->admin->getState('username') ?>
                <div class="clear" style="z-index: 570;"></div>
            </div>
            <div class="st-form-line" style="z-index: 580;">
                <span class="st-labeltext">旧密码:</span>
                <input type="password" value=""  name="now_password" style="width:300px;margin-bottom: 10px;float: left" id="now_password" class="st-success-input" >
                <div class="clear" style="z-index: 570;"></div>
            </div>
            <div class="st-form-line" style="z-index: 580;">
                <span class="st-labeltext">新密码:</span>
                <input type="password" value=""  name="password" style="width:300px;margin-bottom: 10px;float: left" id="password" class="st-success-input"  >
                <div class="clear" style="z-index: 570;"></div>
            </div>
            <div class="st-form-line" style="z-index: 580;">
                <span class="st-labeltext">再次输入新密码:</span>
                <input type="password" value=""  name="re_password" style="width:300px;margin-bottom: 10px;float: left" id="title" class="st-success-input re_password"  >
                <div class="clear" style="z-index: 570;"></div>
            </div>
            <div class="st-form-line button-box" style="z-index: 460;">
                <input type="submit" class="st-button" value="提交" id="submit" name="button">
            </div>
            </form>
        </div>
    </div>


<script type="text/javascript">
    $(function(){
        //创建注册对话框
        $('#edit_user_passwd').validate({
            onkeyup:false,
            submitHandler : function (form) {
                $(form).ajaxSubmit({
                    url : '<?php echo Yii::app()->createUrl('admin/setting/repassword') ?>',
                    type : 'POST',
                    dataType:"json",
                    success : function (responseText) {
                        if (responseText) {
                            if(responseText['status']==1){
                                art.dialog.Talert('<div id="message-ok">'+responseText['message']+'</div>',2,true);
                            }else{
                                art.dialog.Talert('<div id="message-error">'+responseText['message']+'</div>',2);
                            }
                        }else{
                            art.dialog.Talert('<div id="message-error">非法操作</div>',2);
                        }
                    }
                });
            },

            highlight:function(element,errorClass){
                $(element).css('border-color','rgba(230, 0, 0, 0.8)');
                $(element).css('box-shadow','0 1px 1px rgba(0, 0, 0, 0.075) inset, 0 0 8px rgba(230, 0, 0, 0.6)');
                $(element).removeClass("ok");
                $(element).addClass("fault");
            },
            unhighlight:function(element,errorClass){
                $(element).css('border-color','rgba(0, 100, 0, 0.8)');
                $(element).css('box-shadow','0 1px 1px rgba(0, 0, 0, 0.075) inset, 0 0 8px rgba(0, 100, 0, 0.6)');
                $(element).removeClass("fault");
                $(element).addClass("ok");
            },
            rules:{
                now_password : {
                    required : true,
                    minlength : 6,
                    maxlength: 20
                },
                password : {
                    required : true,
                    minlength : 6,
                    maxlength: 20
                },
                re_password : {
                    required : true,
                    equalTo:'#password'
                }

            },
            messages:{
                now_password : {
                    required : '密码不得为空',
                    minlength : $.format('密码不得小于{0}位!'),
                    maxlength: $.format('密码不得大于{0}位!')
                },
                password : {
                    required : '新密码不得为空',
                    minlength : $.format('新密码不得小于{0}位!'),
                    maxlength: $.format('新密码不得大于{0}位!')
                },
                re_password : {
                    required : '密码确认不得为空',
                    equalTo:'密码和密码确认必须一致'
                }
            }
        });
    });
</script>
